<template>
  <div>
    <van-nav-bar
      :z-index="999"
      :fixed="true"
      left-arrow
      @click-left="onClickLeft"
      :placeholder="true"
      title="社区"
    ></van-nav-bar>
    <div class="esoterica_background">
      <div class="panel-bd">
        <van-cell
          class="nBss-cell"
          v-for="(item, i) in bbslist2"
          :key="i"
          @click="href('/PostsPage', item.articleId)"
        >
          <template #icon>
            <div class="nb-avatar">
              <img :src="item.img" alt />
            </div>
          </template>
          <template>
            <div class="info">
              <div class="author">{{ item.name }}</div>
              <div class="postTime">{{ item.articleTime }}</div>
            </div>
            <div class="content">
              <div class="text">
                <span>{{ item.articleTitle }}</span>
              </div>
              <div class="images" v-if="item.imgArray">
                <van-row :gutter="10">
                  <van-col
                    class="images-image"
                    v-for="(subitem, i) in item.imgArray"
                    :key="i"
                  >
                    <img :src="subitem" />
                  </van-col>
                </van-row>
              </div>
              <div class="bottom-icon">
                <div class="icon">
                  <van-icon name="eye-o" />{{ item.articleVisitCount }}
                </div>
                <div class="icon">
                  <!-- <van-icon name="like-o" />{{ item.articleVisitCount }} -->
                </div>
                <div class="icon">
                  <van-icon name="chat-o" />{{ item.articleCommentCount }}
                </div>
              </div>
            </div>
          </template>
        </van-cell>
      </div>
    </div>
    <div @click="href('/ReleasingNotices')" class="releasing-notices">
      <img src="../../assets/images/fabu.png" />
    </div>
  </div>
</template>

<script>
import { SubscribeCommunity } from "../../assets/js/api/exam.js";
export default {
  name: "CommunityList",
  data() {
    return {
      bbslist2: []
    };
  },

  created() {
    let dsBridge = require("dsbridge");
    dsBridge.call("goBack", "", function() {
      history.go(-1);
    });
    console.log(this.$route.params.type);
    SubscribeCommunity(this.$route.params.type).then(res => {
      this.bbslist2 = res.data.articleLists;
      console.log(res);
    });
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    href(url, id) {
      if (url == "/ReleasingNotices") {
        if (localStorage.getItem("token") || sessionStorage.getItem("token")) {
          this.$router.push({ path: url + "/" + this.$route.params.type });
        } else {
          this.$router.push({ path: "/AuthCode" });
        }

        // console.log(url);
        // return;
      } else {
        this.$router.push({ path: url + "/" + id });
      }
    }
  }
};
</script>

<style></style>
